package com.atguigu.hadoop.examples.mapreduce.wordMedian;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public  class WordMedianReducer extends Reducer<IntWritable, IntWritable, IntWritable, IntWritable>
{
    private IntWritable val = new IntWritable();

    public void reduce(IntWritable key, Iterable<IntWritable> values, Reducer<IntWritable, IntWritable, IntWritable, IntWritable>.Context context)
            throws IOException, InterruptedException
    {
        int sum = 0;
        for (IntWritable value : values) {
            sum += value.get();
        }
        this.val.set(sum);
        context.write(key, this.val);
    }
}